package com.sunwayhorizo.health.business.clinic.emr.template.query;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.seam.annotations.Name;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.vocabulary.ActCode;

@Name("MedicalImgQuery")
@Stateless
public class MedicalImgQuery implements MedicalImgQueryLocal
{
    @PersistenceContext(unitName = "sunwayhealth")
    public EntityManager em;

    @SuppressWarnings("unchecked")
    public List<Object> findMedicalImgList() throws Hl7Exception
    {
        StringBuilder jpql = new StringBuilder();
        jpql.append(" select e.actId, e.titleTxt from Document e ");
        jpql.append(" where e.classCode = 'DOC' and e.codeEtsId = '" + ActCode.MEDICALIMG.code().stringValue() + "'");
        List<Object> docs = em.createQuery(jpql.toString()).getResultList();
        return docs;
    }
}
